﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using eLuk.Entity;
// The Settings Flyout item template is documented at http://go.microsoft.com/fwlink/?LinkId=273769

namespace eLuk
{
	public sealed partial class eLukFolderView : SettingsFlyout
	{

		public event FolderSelectionChanged FolderSelectionChanged;

		public eLukFolderView( eLukFolders folders )
		{
			this.InitializeComponent();
			this.folderListView.ItemsSource = folders;
		}

		private void folderListView_ItemClick( object sender, ItemClickEventArgs e )
		{
			eLukFolder folder = e.ClickedItem as eLukFolder;
			if ( folder != null && this.FolderSelectionChanged != null )
			{
				this.FolderSelectionChanged( this, new FolderSelectionChangedEventArgs() { Folder = folder } );
			}
		}

		private void folderListView_SelectionChanged( object sender, SelectionChangedEventArgs e )
		{
			if ( e.AddedItems.Count > 0 )
			{
				eLukFolder folder = e.AddedItems[ 0 ] as eLukFolder;
				if ( folder != null && this.FolderSelectionChanged != null )
				{
					this.FolderSelectionChanged( this, new FolderSelectionChangedEventArgs() { Folder = folder } );
				}
			}
		}

	}

	public delegate void FolderSelectionChanged( object sender, FolderSelectionChangedEventArgs e );
	public class FolderSelectionChangedEventArgs : EventArgs
	{
		public eLukFolder Folder { get; set; }
	}

}
